package com.mxpio.erp.common.equipment.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

/**
 * @Description: 点巡检计划
 * @Author: wxy
 * @Date:   2021-09-16
 * @Version: V1.0
 */
@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_EQUIPMENT_CHECK_PLAN")
@Schema(description="点巡检计划")
public class EquipmentCheckPlan extends BaseEntity {
    private static final long serialVersionUID = 1L;

	/**主键*/
    @Id
    @Generator
    @Column(name = "ID_", updatable = false)
    @Schema(description = "ID")
    private String id;

	/**计划编码*/
    @Column(name = "CODE_")
    @Schema(description = "计划编码")
    private String code;

	/**计划名称*/
    @Column(name = "NAME_")
    @Schema(description = "计划名称")
    private String name;
	/**目标类型*/
    @Dict(dicCode = "ERP_EQUIPMENT_TASK_TARGET_TYPE")
    @Column(name = "TARGET_TYPE_")
    @Schema(description = "目标类型")
    private String targetType;
//	/**起始时间*/
//    @Column(name = "START_TIME_")
//    @Schema(description = "起始时间")
//    private String startTime;

    @Column(name = "START_TIME_")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @Schema(description = "开始日期")//计划开始执行的日期
    private Date startTime;

    @Column(name = "TASK_PLAN_START_TIME_")
    @JsonFormat(timezone = "GMT+8",pattern = "HH:mm:ss")
    @Schema(description = "任务开始时间")//生成的任务，开始执行时间
    private String taskPlanStartTime;
	/**起始时间单位*/
    @Dict(dicCode = "ERP_EQUIPMENT_TASK_RATE_UNIT")
    @Column(name = "STARTTIEM_UNIT_")
    @Schema(description = "起始时间单位")
    private String startTiemUnit;
	/**频率*/
    @Column(name = "RATE_")
    @Schema(description = "频率")
    private String rate;
	/**频率单位*/

    @Dict(dicCode = "ERP_EQUIPMENT_TASK_RATE_UNIT")
    @Column(name = "RATE_UNIT_")
    @Schema(description = "频率单位")
    private String rateUnit;
	/**是否启用*/
    @Dict(dicCode = "ERP_COMMON_YESNO")
    @Column(name = "IS_ENABLE_")
    @Schema(description = "是否启用")
    private Integer isEnable;
	/**是否自动下达*/
    @Dict(dicCode = "ERP_COMMON_YESNO")
    @Column(name = "IS_AUTO_")
    @Schema(description = "是否自动下达")
    private Integer isAuto;
	/**提前下达时间(天)*/
    @Column(name = "ADVANCE_TIME_")
    @Schema(description = "提前下达时间(天)")//按天
    private Integer advanceTime;
	/**下达目标类型*/

    @Dict(dicCode = "ERP_EQUIPMENT_RELEASE_TARGET_TYPE")
    @Column(name = "RELEASE_TARGET_TYPE_")
    @Schema(description = "下达目标类型")
    private String releaseTargetType;

    @Column(name = "END_LOOP_TYPE_")
    @Schema(description = "结束类型")
    @Dict(dicCode = "ERP_EQUIPMENT_PLAN_END_LOOP_TYPE")
    private String endLoopType;//循环、频次、定时

    @Column(name = "END_TIMES_")
    @Schema(description = "结束次数")//结束类型为频次时
    private Integer endTimes;

    @Column(name = "END_DATE_")
    @Schema(description = "结束日期")//结束类型为定时
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    private Date endDate;

	/**下达目标*/
    @Dict(dicEntity = User.class, dicText = "nickname", dicCode = "username")
    @Column(name = "TARGET_")
    @Schema(description = "下达目标")
    private String target;

    /**下达目标*/
    @Column(name = "TARGET_NAME_")
    @Schema(description = "下达目标")
    private String targetName;

	/**派工模式*/

    @Dict(dicCode = "ERP_EQUIPMENT_DISPATCH_MODE")
    @Column(name = "DISPATCH_MODE_")
    @Schema(description = "派工模式")
    private String dispatchMode;

	/**上次计划开始时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @Column(name = "LAST_PLAN_START_")
    @Schema(description = "上次计划开始时间")
    private Date lastPlanStart;

	/**上次计划结束时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @Column(name = "LAST_PLAN_END_")
    @Schema(description = "上次计划结束时间")
    private Date lastPlanEnd;

    @Column(name = "EXEC_STATUS_")
    @Schema(description = "执行状态")
    @Dict(dicCode = "ERP_EQUIPMENT_PLAN_EXEC_STATUS")//待执行1，执行中2，已完成3，已作废4
    private String execStatus;

    @Column(name = "PLAN_TYPE_")
    @Schema(description = "计划类型")
    @Dict(dicCode = "ERP_EQUIPMENT_UPKEEP_TYPE")
    private String planType;//周期、临时

    @Column(name = "CYCLE_INDEX_")
    @Schema(description = "循环次数")
    private Integer cycleIndex;

    @Column(name = "MEMO_")
    @Schema(description = "备注")
    private String memo;

    @Column(name = "IS_HOLD_")
    @Schema(description = "是否占用（0-否；1-是）")
    @Dict(dicCode = "ERP_COMMON_YESNO")
    private Integer isHold;

    @Column(name = "IS_PUSH_")
    @Schema(description = "是否推送")
    @Dict(dicCode = "ERP_COMMON_YESNO") //0：不推送 1：推送
    private String isPush;

}
